import xlsxwriter
import os
from cgai_time.Time import TimeHandler

# 创建表格路径
path = os.path.join(os.path.abspath(''),'xlsxwriter_task.xlsx')

# 创建表格和分页
wb = xlsxwriter.Workbook(path)
ws = wb.add_worksheet('动画')

# 单元格样式
style_row = wb.add_format({'font_size': 20, 'bold': 1,
                'bg_color':'#666666', 'align':'center',
                'valign':'vcenter', 'border':1})

style_col = wb.add_format({'font_size': 15, 'bold': 1,
                'bg_color':'#666666', 'align':'center',
                'valign':'vcenter', 'border':1})
style_col1 = wb.add_format({'font_size': 10, 'bold': 1,
                'bg_color':'#666666', 'align':'center',
                'valign':'vcenter', 'border':1})

# 合并网格
ws.merge_range(1, 0, 5, 0, '')
ws.merge_range(6, 0, 10, 0, '')
ws.merge_range(11, 0, 15, 0, '')
ws.merge_range(16, 0, 20, 0, '')
ws.merge_range(21, 0, 25, 0, '')
ws.merge_range(26, 0, 30, 0, '')
ws.merge_range(31, 0, 35, 0, '')
ws.merge_range(36, 0, 40, 0, '')
ws.merge_range(41, 0, 45, 0, '')
ws.merge_range(46, 0, 50, 0, '')

# 获取日期
ct = TimeHandler()
column_time =[]
start_time = '2021-8-2'

for i in range(1,7):
    if start_time == '2021-8-2':
        column_time.append(start_time)
        start_time = ct.dateAdd(start_time,i)
        column_time.append(start_time)
    else:
        print('i:',i)
        next_time = ct.dateAdd(start_time,i-1)
        column_time.append(next_time)
print(column_time)

# 星期几
weekday = []
for i in column_time:
    weekday_number = ct.getWeekdayCName(i)
    weekday.append(weekday_number)
print(weekday)

# 日期+星期几
column_weekday = []
for i in range(len(column_time)):
    column_list = [column_time[i], weekday[i]]
    column_time1 = '\n'.join(column_list)
    column_weekday.append(column_time1)
print(column_weekday)

# 人物名称
column_name = ['韩超', '赵文豪', '陈杰', '田成靖', '黄旭',
            '杨航', '桂艳山', '贺占军', '孙圣研', '王雨']

# 每日任务
col_han = ['预视', '预视', '预视', '预视', '预视', '预视', '预视']
col_zhao = ['预视', '预视', '预视', '预视', '预视', '预视', '预视']
col_chen = ['学习脚本', '学习脚本', '学习脚本', '学习脚本', '预视',
            '预视', '预视']
col_tian = ['预视', '预视', '预视', '预视', '预视', '预视', '预视']
col_huang = ['预视', '预视', '预视', '预视', '预视', '预视', '预视']
col_yang = ['动捕+面捕', '蝶骨族百姓_01-rig','蝶骨族百姓_04-rig',
            '章鲨婴儿阶段-rig', '章鲨触角阶段-rig', '章鲨婴儿阶段-rig',
            '章鲨婴儿阶段-rig']
col_yang1 = ['蝶骨族百姓_01-rig', '蝶骨族百姓_02-rig', '蝶骨族百姓_05-rig',
            '', '', '', '']

col_yang = ['', '蝶骨族百姓_03-rig', '蝶骨族百姓_06-rig',
            '章鲨婴儿阶段-rig', '章鲨触角阶段-rig', '章鲨婴儿阶段-rig',
            '章鲨婴儿阶段-rig']
col_gui = ['预视', '预视', '预视', '预视', '预视', '预视', '预视']
col_sun = ['FNDH152_0010-ani', 'FNDH165_0320-ani','FNDH165_0320-ani',
           '菡萏化人形测试-ani','HYX10_02_376-ani', 'G8601_01_001-ani',
           'G8601_01_001-ani']
col_sun1 = ['FNDH_返修预留', 'FNDH_返修预留','FNDH_返修预留', '动捕+面捕',
            '动捕+面捕', '通天门-layout','通天门-layout']



col_he = ['预视', '预视', '预视', '预视', '预视', '预视', '预视']
col_wang = ['动捕+面捕', '动捕+面捕\n蝶骨族百姓_01-ani\n蝶骨族百姓_02-ani',
            '动捕+面捕\n蝶骨族百姓_03-ani\n蝶骨族百姓_04-ani',
            '动捕+面捕\n蝶骨族百姓_05-ani\n蝶骨族百姓_06-ani\nHBL06-05-057-ani',
            '动捕+面捕\nHYX43_01_012-ani\nHBL06-05-057-ani\nHYX43_01_017-ani',
            '动捕+面捕\nHYX43_01_018-ani\nHBL06-05-067-ani\nHBL06-05-058-ani','']




# style_tian = style_han
# style_huang = style_han
# style_yang =
# style_gui = style_han
# style_sun =
# style_he = style_han
# style_wang =

# 往xlsx添加内容
ws.write_row(0,1,column_weekday)
ws.write('A2',column_name[0])
ws.write('A7',column_name[1])
ws.write('A12',column_name[2])
ws.write('A17',column_name[3])
ws.write('A22',column_name[4])
ws.write('A27',column_name[5])
ws.write('A32',column_name[6])
ws.write('A37',column_name[7])
ws.write('A42',column_name[8])
ws.write('A47',column_name[9])


ws.write_row(1,1,col_han)
ws.write_row(6,1,col_zhao)
ws.write_row(11,1,col_chen)
ws.write_row(16,1,col_tian)
ws.write_row(21,1,col_huang)
ws.write_row(26,1,col_yang)
ws.write_row(31,1,col_gui)
ws.write_row(36,1,col_sun)
ws.write_row(41,1,col_he)
ws.write_row(46,1,col_wang)

wb.close()
os.startfile(os.path.join(os.path.abspath(''),'xlsxwriter_task.xlsx'))